(function(_,$){
	if(!_.Changer){
		return ;
	}
	_.Changer.addHandler({
		name : "datagrid",
		selector : "table[changer='datagrid']",
		handler : function(objs , parent){
			objs.each(function(i){
				var table = objs.eq(i);
				table.removeAttr("changer");	//移除changer属性
				//defaultConfig	默认配置
				var dc = {
					height : "100%"
				};
				var config = table.attr("config");	//配置信息
				if(config){config = eval("("+config+")");}
				$.extend(dc,config);	//合并配置
				
				
				//调整列宽
				var tds = table.find("tbody tr").eq(0).children("td");
				var ths = table.find("thead tr").eq(0).children("th");
				if(tds.size() > 0){
					tds.each(function(i){
						var td = tds.eq(i);
						ths.eq(i).attr("width",td.width());
					});
				}
				
				table.flexigrid({
					resizable : false
				});
				
				var parent = table.parent();
				var cDrag = parent.prev();
				var pre = cDrag.prev();
				var container = parent.parent();	//最外层的容器
				//设置高度
				var setHeight = function(){
					var height = dc.height;
					if(typeof dc.height == "string"){	//如果是百分比
						height = container.parent().sizeValueByPercent(dc.height).height;
					}
					container.height(height);
					parent.height(height - pre.height() - 2);
					cDrag.height(height).children().height(height);
				};
				setHeight();
				container.parent().resizCall(setHeight);
			});
		}
	});
})(jDreamer,jQuery);